package com.cictec.middleware.tde.rm.disp.receiver.handler;

import org.apache.mina.core.session.IoSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.cictec.middleware.tde.rm.disp.annotation.HandleMessages;
import com.cictec.middleware.tde.rm.disp.receiver.AbstractReceiverHandler;
import com.cictec.middleware.tde.rm.protocol.TerminalMessage;
import com.cictec.middleware.tde.rm.protocol.rm.message.Rm0x08TerminalMessage;

/**
 * 关机请求,接收指令应答确认
 * 
 * @author Administrator
 *
 */
@Component
@HandleMessages(0x08)
public class TerminalShutdownHandler extends AbstractReceiverHandler {

	private static Logger logger = LoggerFactory.getLogger(TerminalShutdownHandler.class);

	@Override
	public void handleMessage(TerminalMessage message, IoSession session) {
		Rm0x08TerminalMessage msg = (Rm0x08TerminalMessage) message;

		sendMessageToTerminal(createResponse(message), session);

		logger.debug("【0x08关机请求】终端 {} Session {}  {}", message.getTerminalId(), message.getSessionId(), JSON.toJSONString(msg));

	}

}
